//生产环境： https://airbim.com/mixingstation
//开发环境：http://192.168.0.110:8989/mixingstation
// const baseUrl = 'http://192.168.0.109:8080/mixingstation'

const request = (url, config = {}) => {
	uni.showLoading({
		title: '加载中...'
	})
	let token = uni.getStorageSync('token');
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'http://139.224.100.143:9003' + url,
			method: config.method || 'get',
			header: {
				"token": token,
				// "content-type": "application/x-www-form-urlencoded",
				"content-type": "application/json;charset=UTF-8"
			},
			data: {
				...config.data || '',
			},
			success: (res) => {
				if ( res.data.code == 0) {
					uni.showToast({
						icon: 'none',
						title: res.data.msg,
						duration: 1000
					});
				}
				resolve(res)
			},
			fail: (err) => {
				reject(err),
				uni.showToast({
					icon: 'none',
					title: '请求失败',
					duration: 1000,
				})
			},
			complete: () => {
				uni.hideLoading()
			}
		})
	})
}
export default request